<div class="content-section introduction">
    <div>
        <span class="feature-title">Checkbox</span>
        <span>Checkbox is an extension to standard checkbox element with skinning capabilities.</span>
    </div>
</div>

<div class="content-section implementation">
    <h3 class="first">Basic</h3>
    <div class="ui-g" style="width:250px;margin-bottom:10px">
        <div class="ui-g-12"><p-checkbox name="group1" value="New York" label="New York" [(ngModel)]="selectedCities"></p-checkbox></div>
        <div class="ui-g-12"><p-checkbox name="group1" value="San Francisco" label="San Francisco" [(ngModel)]="selectedCities"></p-checkbox></div>
        <div class="ui-g-12"><p-checkbox name="group1" value="Los Angeles" label="Los Angeles" [(ngModel)]="selectedCities"></p-checkbox></div>
    </div>

    Selected Cities: <span *ngFor="let city of selectedCities" style="margin-right:10px">{{city}}</span>

    <h3>Preselection</h3>
    <div class="ui-g" style="width:250px;margin-bottom:10px">
        <div class="ui-g-12"><p-checkbox name="group2" value="Technology" label="Technology" [(ngModel)]="selectedCategories"></p-checkbox></div>
        <div class="ui-g-12"><p-checkbox name="group2" value="Finance" label="Finance" [(ngModel)]="selectedCategories"></p-checkbox></div>
        <div class="ui-g-12"><p-checkbox name="group2" value="Sports" label="Sports" [(ngModel)]="selectedCategories"></p-checkbox></div>
        <div class="ui-g-12"><p-checkbox name="group2" value="Entertainment" label="Entertainment" [(ngModel)]="selectedCategories"></p-checkbox></div>
    </div>

    Selected Categories: <span *ngFor="let cat of selectedCategories" style="margin-right:10px">{{cat}}</span>
    
    <h3>Boolean - {{checked}}</h3>
    <p-checkbox [(ngModel)]="checked" binary="true"></p-checkbox>
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header="Documentation">
            <h3>Import</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;CheckboxModule&#125; from 'primeng/primeng';
</code>
</pre>

            <h3>Getting Started</h3>
            <p>Checkbox can either be used in multiple selection with other checkboxes or as a single checkbox to provide a boolean value.</p>
            
            <h4>Multiple Values</h4>
            <p>Multiple mode is enabled by default, ngModel property refers to an array to bind the selected values.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-checkbox name="groupname" value="val1" [(ngModel)]="selectedValues"&gt;&lt;/p-checkbox&gt;
&lt;p-checkbox name="groupname" value="val2" [(ngModel)]="selectedValues"&gt;&lt;/p-checkbox&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class ModelComponent &#123;

    selectedValues: string[] = [];

&#125;
</code>
</pre>

            <p>As ngModel is two-way binding enabled, prepopulating the model array with values is enough to display the related
            checkboxes as checked by default.</p>
<pre>
<code class="language-typescript" pCode ngNonBindable>
export class ModelComponent &#123;

    selectedValues: string[] = ['val1','val2'];

&#125;
</code>
</pre>

        <h4>Label</h4>
        <p>The label attribute provides a label text for the checkbox. This label is also clickable and toggles the checked state.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-checkbox name="groupname" value="val1" label="Value 1" [(ngModel)]="selectedValues"&gt;&lt;/p-checkbox&gt;
&lt;p-checkbox name="groupname" value="val2" label="Value 2" [(ngModel)]="selectedValues"&gt;&lt;/p-checkbox&gt;
</code>
</pre>

        <h4>Boolean Value</h4>
        <p>A single boolean value can be bound using the ngModel property as well by enabling the binary option.</p>
<pre>
<code class="language-typescript" pCode ngNonBindable>
export class ModelComponent &#123;

    value: boolean;

&#125;
</code>
</pre>

<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-checkbox [(ngModel)]="value" binary="true"&gt;&lt;/p-checkbox&gt;
</code>
</pre>

        <h3>Model Driven Forms</h3>
        <p>Checkbox can be used in a model driven form as well.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-checkbox formControlName="agreed"&gt;&lt;/p-checkbox&gt;
</code>
</pre>

            <h3>Properties</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>name</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Name of the checkbox group.</td>
                        </tr>
                        <tr>
                            <td>value</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Value of the checkbox.</td>
                        </tr>
                        <tr>
                            <td>label</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Label of the checkbox.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the element should be disabled.</td>
                        </tr>
                        <tr>
                            <td>binary</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Allows to select a boolean value instead of multiple values.</td>
                        </tr>
                        <tr>
                            <td>tabindex</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Index of the element in tabbing order.</td>
                        </tr>
                        <tr>
                            <td>inputId</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Identifier of the focus input to match a label defined for the component.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>object</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Events</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onChange</td>
                            <td>checked: Boolean value to represent new state of checkbox.</td>
                            <td>Callback to invoke on checkbox click.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Styling</h3>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>ui-chkbox</td>
                            <td>Container element</td>
                        </tr>
                        <tr>
                            <td>ui-chkbox-box</td>
                            <td>Container of icon.</td>
                        </tr>
                        <tr>
                            <td>ui-chkbox-icon</td>
                            <td>Icon element.</td>
                        </tr>
                        <tr>
                            <td>ui-chkbox-label</td>
                            <td>Label element.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Dependencies</h3>
            <p>None.</p>
        </p-tabPanel>
        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/checkbox" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
            
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;h3 class="first"&gt;Basic&lt;/h3&gt;
&lt;div class="ui-g" style="width:250px;margin-bottom:10px"&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-checkbox name="group1" value="New York" label="New York" [(ngModel)]="selectedCities"&gt;&lt;/p-checkbox&gt;&lt;/div&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-checkbox name="group1" value="San Francisco" label="San Francisco" [(ngModel)]="selectedCities"&gt;&lt;/p-checkbox&gt;&lt;/div&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-checkbox name="group1" value="Los Angeles" label="Los Angeles" [(ngModel)]="selectedCities"&gt;&lt;/p-checkbox&gt;&lt;/div&gt;
&lt;/div&gt;

Selected Cities: &lt;span *ngFor="let city of selectedCities" style="margin-right:10px"&gt;{{city}}&lt;/span&gt;

&lt;h3&gt;Preselection&lt;/h3&gt;
&lt;div class="ui-g" style="width:250px;margin-bottom:10px"&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-checkbox name="group2" value="Technology" label="Technology" [(ngModel)]="selectedCategories"&gt;&lt;/p-checkbox&gt;&lt;/div&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-checkbox name="group2" value="Finance" label="Finance" [(ngModel)]="selectedCategories"&gt;&lt;/p-checkbox&gt;&lt;/div&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-checkbox name="group2" value="Sports" label="Sports" [(ngModel)]="selectedCategories"&gt;&lt;/p-checkbox&gt;&lt;/div&gt;
    &lt;div class="ui-g-12"&gt;&lt;p-checkbox name="group2" value="Entertainment" label="Entertainment" [(ngModel)]="selectedCategories"&gt;&lt;/p-checkbox&gt;&lt;/div&gt;
&lt;/div&gt;

Selected Categories: &lt;span *ngFor="let cat of selectedCategories" style="margin-right:10px"&gt;{{cat}} &lt;/span&gt;

&lt;h3&gt;Boolean - {{checked}}&lt;/h3&gt;
&lt;p-checkbox [(ngModel)]="checked" binary="true"&gt;&lt;/p-checkbox&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class CheckboxDemo &#123;

    selectedCities: string[] = [];

    selectedCategories: string[] = ['Technology', 'Sports'];

    checked: boolean = false;
&#125;
</code>
</pre>
        </p-tabPanel>
    </p-tabView>
</div>
